<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Repository\RepositoryInterface\GroupInterface;
use Illuminate\Http\Request;

class GroupController extends Controller
{
    //
    protected $group;

    public function __construct(GroupInterface $group)
    {
        $this->group = $group;
    }
    /**
     * 加入拼团
     */
    public function JoinGroup(Request $request)
    {
        $uid = $request->input('uid');
        $kid=$request->input('kid');
        $gid = $request->input('gid');
        $cid=$request->input('cid');
        $goods_id=$request->input('goods_id');
        $num=$request->input('num');
        $res =  $this->group->JoinGroup($uid,$gid,$cid,$kid,$num);
        return $res;
    }
    /**
     * @param Request $request
     * @return mixed
     * 用户开团
     */
    public function UserInitGroup(Request $request)
    {
        $uid = $request->input('uid');
        $cid=$request->input('cid');
        $num=$request->input('num');
        $time=$request->input('time');
        $res=$this->group->UserInitGroup($uid,$cid,$num,  $time);
        return $res;
    }
    public function UserExitGroup(Request $request)
    {
        $uid=$request->input('uid');
        $kid=$request->input('kid');
        $cid=$request->input('cid');
        $res=$this->group->UserExitGroup($uid,$kid,$cid);
        return $res;
    }
    public function HeadExitGroup(Request $request)
    {
        $uid=$request->input('uid');
        $cid=$request->input('cid');
        $res=$this->group->HeadExitGroup($uid,$cid);
        return $res;
    }
    public function HeadGroupList()
    {
        $res=$this->group->HeadGroupList();
        return  $res;
        return success('success',$res);
    }
    public function GroupProduct()
    {
        $res=$this->group->GroupProductList();
        return success('success',$res);
    }


}
